package twitter.client.util;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

import android.content.Context;
import android.widget.Toast;

public class Utils {
	private static Pattern PATTERN_CLIENT_NAME = Pattern.compile("<.+?>");

	private static String getTwitterClientNameFromSource(String source) {
		return PATTERN_CLIENT_NAME.matcher(source).replaceAll("");
	}

	public static String getTweetInfo(Date createdAt, String source) {
		SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
		StringBuilder info = new StringBuilder();
		info.append(format.format(createdAt)).append(" ");
		info.append(getTwitterClientNameFromSource(source)).append("から");

		return info.toString();
	}

	public static void showToast(Context context, String msg) {
		Toast toast = Toast.makeText(context, msg, Toast.LENGTH_LONG);
		toast.show();
	}
}
